package top.fullj.remoting.message;

import java.io.Serializable;

/**
 * @author bruce.wu
 * @since 2022/2/14 15:39
 */
public class InvokeResponse implements Serializable {

    private static final long serialVersionUID = -1425246164671680807L;

    private boolean success;

    private Object result;

    private String message;

    public InvokeResponse() {

    }

    public InvokeResponse(Object result) {
        this.success = true;
        this.result = result;
    }

    public InvokeResponse(String error) {
        this.success = false;
        this.message = error;
    }

    public InvokeResponse(Throwable tr) {
        this.success = false;
        this.message = tr.getMessage() + "[" + tr.getClass().getSimpleName() + "]";
    }

    public boolean isSuccess() {
        return success;
    }

    public Object getResult() {
        return result;
    }

    public String getMessage() {
        return message;
    }

}
